package com.java.collection;

import java.util.ArrayList;
import java.util.LinkedList;

public class LinkedListDemo {
    public static void main(String[] args) {
        //创建泛型linkedList
        LinkedList<String> linkedList = new LinkedList<>();
        //添加特定类型
        linkedList.add("张三");
        linkedList.add("李四");
        linkedList.add("王五");
        //在开头和结尾插入数据
        linkedList.addFirst("赵六");
        linkedList.addLast("钱七");
        //在开头和结尾删除数据
        linkedList.removeFirst();
        linkedList.removeLast();
        //获得开头和结尾的数据
        System.out.println("开头的数据是："+linkedList.getFirst());
        System.out.println("结尾的数据是："+linkedList.getLast());

    }
}
